/*
 * uart print
 */
#include "uart_print.h"
#include "usart.h"
#include <stdio.h>
#include <stdarg.h>

void uart_putchar(char ch)
{
  HAL_UART_Transmit(&huart1, (uint8_t*)&ch, 1, HAL_MAX_DELAY);
}

int uart_print(char* fmt, ...)
{
  char sprint_buf[256]={0};
  int n=0;

  va_list args;
  va_start(args, fmt);
  n = vsprintf(sprint_buf, fmt, args);
  va_end(args);

  HAL_UART_Transmit(&huart1, (uint8_t*)&sprint_buf[0], n, HAL_MAX_DELAY);

  return (int)n;
}
